/*jslint maxerr: 50, indent: 4, browser: true */
/*global define */

(function () {
    "use strict";

    define("array.shift", ["mergeModules", "init", "array.push", "array.length", "array.slice"], function (make) {
        var buri = make.mergeModules(arguments),
            config = {
                "compatability": {}
            },
            func = [].constructor.prototype.shift,
            shift;


        if (!config.compatability.all && !config.compatability["array.push"] && typeof func === "function") {
            shift = function (array) {
                return func.call(array);
            };
        } else {
            shift = function (array) {
                var element = array[0],
                    tempArray = buri.array.slice(array, 1),
                    length = buri.array.length(tempArray),
                    i = 0;

                array.length = 0;
                while (i < length) {
                    buri.array.push(array, tempArray[i]);
                    i += 1;
                }

                return element;
            };
        }

        shift.init = function (options) {
            buri.init(config, options);
            buri.array.length(config);
            buri.array.push(config);
            buri.array.slice(config);
        };

        return {
            "array": {
                "shift": shift
            }
        };
    });
}());
